package com.netcracker.lab1.view;

import com.netcracker.lab1.controller.MusicTrackController;
import com.netcracker.lab1.utils.ConvertDurations;
import com.netcracker.lab1.utils.SortComparator;

import javax.swing.table.AbstractTableModel;
import java.util.Collections;

/**
 * Created with IntelliJ IDEA.
 * User: nocturne
 * Date: 25.01.13
 * Time: 23:28
 * To change this template use File | Settings | File Templates.
 */
class TableModelPlaylist extends AbstractTableModel {

    private MusicTrackController musicTrackController = new MusicTrackController();

    public TableModelPlaylist(){

    }

    @Override
    public int getRowCount() {
        return musicTrackController.getSizeLibrary();
    }
    @Override
    public int getColumnCount() {
        return 5;
    }

    @Override
    public Object getValueAt(int r, int c) {
        switch (c) {
            case 0:
                return musicTrackController.findTrackById(r).getAuthor();
            case 1:
                return musicTrackController.findTrackById(r).getTitle();
            case 2:
                return ConvertDurations.convertDuration(musicTrackController.findTrackById(r).getDuration());
            case 3:
                return musicTrackController.findTrackById(r).getAlbum();
            case 4:
                return musicTrackController.findTrackById(r).getGenre();
            default:
                return "";
        }
    }

    @Override
    public String getColumnName(int c) {
        String result = "";
        switch (c) {
            case 0:
                result = "Author";
                break;
            case 1:
                result = "Title";
                break;
            case 2:
                result = "Duration";
                break;
            case 3:
                result = "Album";
                break;
            case 4:
                result = "Genre";
                break;
        }
        return result;
    }



}
